package com.englisheveryday.media;

import android.media.MediaPlayer;
/**
 * 自定义Mediaplayer 添加相关的状态改变
 * @author cheney
 *
 */
public class EEMediaPlayer extends MediaPlayer {
	
	private OnStateChangeListener onPauseListener;//播放器暂停时
	private OnStateChangeListener onStartListener;//播放器开始播放
	private OnStateChangeListener onStopListener;

	@Override
	public void pause() throws IllegalStateException {
		super.pause();
		if(onPauseListener!=null)
			onPauseListener.onStateChanged();
	}

	@Override
	public void release() {
		super.release();
	}

	@Override
	public void reset() {
		super.reset();
	}

	@Override
	public void start() throws IllegalStateException {
		super.start();
		if(onStartListener!=null)
			onStartListener.onStateChanged();
	}

	@Override
	public void stop() throws IllegalStateException {
		super.stop();
	}

	/**
	 * 播放器状态改变接口
	 * @author cheney
	 *
	 */
	public interface OnStateChangeListener{
		public void onStateChanged();
	}

	public OnStateChangeListener getOnPauseListener() {
		return onPauseListener;
	}

	public void setOnPauseListener(OnStateChangeListener onPauseListener) {
		this.onPauseListener = onPauseListener;
	}

	public OnStateChangeListener getOnStartListener() {
		return onStartListener;
	}

	public void setOnStartListener(OnStateChangeListener onStartListener) {
		this.onStartListener = onStartListener;
	}

	public OnStateChangeListener getOnStopListener() {
		return onStopListener;
	}

	public void setOnStopListener(OnStateChangeListener onStopListener) {
		this.onStopListener = onStopListener;
	};
}
